﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Salon
{
    public partial class ColorComboBox : FilterComboBox
    {
        public ColorComboBox()
        {
            this.DropDownStyle = ComboBoxStyle.DropDownList;
            InitializeComponent();
        }
        /*
        public ColorComboBox(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }*/

        /// <summary>
        /// Inicjalizuje kontrolkę danymi pobranymi z bazy.
        /// </summary>
        public void Initialize()
        {
            IList<DictColorItem> list = ServiceFactory.getDictService().getColors(new Filter("active", 1).asList());

            this.DataSource = list;
            this.DisplayMember = "DictValue";
            this.ValueMember = "Id";

            this.SelectedItem = null;
        }
        /// <summary>
        /// Inicjalizuje kontrolkę danymi pobranymi z bazy.
        /// Parametr id wybiera element z listy
        /// </summary>
        public void Initialize(int id)
        {
            IList<DictColorItem> list = ServiceFactory.getDictService().getColors();

            this.DataSource = list;
            this.DisplayMember = "DictValue";
            this.ValueMember = "Id";

            this.SelectedValue = id;
        }

        public override String ColumnValue { get { return this.SelectedValue != null ? this.SelectedValue.ToString() : ""; } }

        public override void CleanUp()
        {
            this.SelectedItem = null;
        }
    }
}
